package com.example.martian.huobi.config;

import com.example.martian.huobi.client.*;
import com.example.martian.huobi.constant.HuobiOptions;
import com.example.martian.huobi.constant.Options;
import com.example.martian.huobi.service.*;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Configuration
@EnableConfigurationProperties(HuobiOptions.class)
public class ClientFactory {

    @Resource
    private Options options;

    @ConditionalOnMissingBean
    @Bean
    public AccountClient accountClient() {
        return new HuobiAccountService(options);
    }

    @ConditionalOnMissingBean
    @Bean
    public AlgoClient algoClient() {
        return new HuobiAlgoService(options);
    }

    @ConditionalOnMissingBean
    @Bean
    public CrossMarginClient crossMarginClient() {
        return new HuobiCrossMarginService(options);
    }

    @ConditionalOnMissingBean
    @Bean
    public ETFClient ETFClient() {
        return new HuobiETFService(options);
    }

    @ConditionalOnMissingBean
    @Bean
    public GenericClient genericClient() {
        return new HuobiGenericService(options);
    }

    @ConditionalOnMissingBean
    @Bean
    public IsolatedMarginClient isolatedMarginClient() {
        return new HuobiIsolatedMarginService(options);
    }

    @ConditionalOnMissingBean
    @Bean
    public MarketClient marketClient() {
        return new HuobiMarketService(options);
    }

    @ConditionalOnMissingBean
    @Bean
    public SubUserClient subUserClient() {
        return new HuobiSubUserService(options);
    }

    @ConditionalOnMissingBean
    @Bean
    public TradeClient tradeClient() {
        return new HuobiTradeService(options);
    }

    @ConditionalOnMissingBean
    @Bean
    public WalletClient walletClient() {
        return new HuobiWalletService(options);
    }
}
